home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / ddj0492.zip / DFLT11.ZIP / MOUSE.C < prev    next >
Text File  |  1992-01-09  |  2KB  |  98 lines

  1. /* ------------- mouse.c ------------- */
  2.  
  3. #include "dflat.h"
  4.  
  5. static union REGS regs;
  6.  
  7. static void near mouse(int m1,int m2,int m3,int m4)
  8. {
  9.     regs.x.dx = m4;
  10.     regs.x.cx = m3;
  11.     regs.x.bx = m2;
  12.     regs.x.ax = m1;
  13.     int86(MOUSE, ®s, ®s);
  14. }
  15.  
  16. /* ---------- reset the mouse ---------- */
  17. void resetmouse(void)
  18. {
  19.     mouse(0,0,0,0);
  20. }
  21.  
  22. /* ----- test to see if the mouse driver is installed ----- */
  23. BOOL mouse_installed(void)
  24. {
  25.     unsigned char far *ms;
  26.     ms = MK_FP(peek(0, MOUSE*4+2), peek(0, MOUSE*4));
  27.     return (SCREENWIDTH <= 80 && ms != NULL && *ms != 0xcf);
  28. }
  29.  
  30. /* ------ return true if mouse buttons are pressed ------- */
  31. int mousebuttons(void)
  32. {
  33.     if (mouse_installed())    {
  34.         mouse(3,0,0,0);
  35.         return regs.x.bx & 3;
  36.     }
  37.     return 0;
  38. }
  39.  
  40. /* ---------- return mouse coordinates ---------- */
  41. void get_mouseposition(int *x, int *y)
  42. {
  43.     if (mouse_installed())    {
  44.         mouse(3,0,0,0);
  45.         *x = regs.x.cx/8;
  46.         *y = regs.x.dx/8;
  47.         if (SCREENWIDTH == 40)
  48.             *x /= 2;
  49.     }
  50. }
  51.  
  52. /* -------- position the mouse cursor -------- */
  53. void set_mouseposition(int x, int y)
  54. {
  55.     if (mouse_installed())    {
  56.         if (SCREENWIDTH == 40)
  57.             x *= 2;
  58.         mouse(4,0,x*8,y*8);
  59.     }
  60. }
  61.  
  62. /* --------- display the mouse cursor -------- */
  63. void show_mousecursor(void)
  64. {
  65.     if (mouse_installed())
  66.         mouse(1,0,0,0);
  67. }
  68.  
  69. /* --------- hide the mouse cursor ------- */
  70. void hide_mousecursor(void)
  71. {
  72.     if (mouse_installed())
  73.         mouse(2,0,0,0);
  74. }
  75.  
  76. /* --- return true if a mouse button has been released --- */
  77. int button_releases(void)
  78. {
  79.     if (mouse_installed())    {
  80.         mouse(6,0,0,0);
  81.         return regs.x.bx;
  82.     }
  83.     return 0;
  84. }
  85.  
  86. /* ----- set mouse travel limits ------- */
  87. void set_mousetravel(int minx, int maxx, int miny, int maxy)
  88. {
  89.     if (mouse_installed())    {
  90.         if (SCREENWIDTH == 40)    {
  91.             minx *= 2;
  92.             maxx *= 2;
  93.         }
  94.         mouse(7, 0, minx*8, maxx*8);
  95.         mouse(8, 0, miny*8, maxy*8);
  96.     }
  97. }
  98.